# 主函数入口
from combinations.config_parser import load_config
import importlib

config_list = [
    "产品拼接",
    "图片_视频_口播",
    "图片口播",
    "滚动展示",
    "稳定性效果",

    "美甲展示",
    "主题蹭款",
    # "labubu"
    "模特图穿插",
    "穿搭展示",
]
if __name__ == "__main__":
    for conf in config_list:
        print(f"重新加载配置：{conf}")
        load_config(conf)

        # todo开始前读取conflist 将conf 给 config 文件的变量赋值
        # COMBO_NAME_PREFIX、MATERIAL_MAPPING、TEMPLATE_NAME、BASE_DIR
        # 之后再进行跑程序
        from combinations import main as comb
        from combinations import draft_handler
        from combinations import markdown_generator
        from combinations import utils
        from combinations.rpa import main

        # 在每次循环中重新加载模块
        importlib.reload(comb)
        importlib.reload(draft_handler)
        importlib.reload(markdown_generator)
        importlib.reload(utils)
        importlib.reload(main)
        from combinations.config import START, END

        # 赋值这四个变量
        start = START
        # 结束 -1 则说明不限制
        end = END
        # 依据音频文件进行裁剪（在视频导出后进行操作）
        video_cut_by_audio_folder = ""
        # 抠图
        kou_tu = False
        # 字幕
        zi_mu = False
        # 是否使用自定义脚本
        # 是否随机打乱组合结果，进行生成草稿
        is_random = False
        # 删除复制的草稿
        enable_delete = True
        # 动态帧扰乱
        frame_sampling = False

        try:
            # # 生成组合和剪映草稿
            combinations_list = comb.combination(start=start, end=end,
                                                 is_random=is_random, zi_mu=zi_mu, kou_tu=kou_tu,
                                                 enable_delete=enable_delete,
                                                 frame_sampling=frame_sampling)

            # 抽帧处理

        except Exception as e:
            print(f"组合生成失败：{e}")
            break
